package org.softmed.rest.server.xstream;

import java.math.BigInteger;

import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.SingleValueConverter;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class BigIntegerConverter implements SingleValueConverter {

	public BigIntegerConverter() {

	}

	// @Override
	// public void marshal(Object arg0, HierarchicalStreamWriter arg1,
	// MarshallingContext arg2) {
	// BigInteger bd = (BigInteger) arg0;
	// arg1.setValue(bd.toString());
	//
	// }
	//
	// @Override
	// public Object unmarshal(HierarchicalStreamReader arg0,
	// UnmarshallingContext arg1) {
	//
	// BigInteger bd = new BigInteger(arg0.getValue());
	// return bd;
	//
	// }

	@Override
	public boolean canConvert(Class arg0) {
		return arg0 == BigInteger.class;
	}

	@Override
	public Object fromString(String arg0) {
		BigInteger bd = new BigInteger(arg0);
		return bd;
	}

	@Override
	public String toString(Object arg0) {
		BigInteger bd = (BigInteger) arg0;
		return bd.toString();
	}

}
